package com.demo.simpletestapp

import android.app.ActivityOptions
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.Window
import android.view.WindowManager
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.demo.simpletestapp.exoplayer.LiveStreamActivity
import com.demo.simpletestapp.utils.Utils
import com.demo.simpletestapp.webview.WebViewTestActivity

class SplashActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
//        requestWindowFeature(Window.FEATURE_NO_TITLE);// 隐藏标题
//        window.setFlags(
//            WindowManager.LayoutParams.FLAG_FULLSCREEN,
//            WindowManager.LayoutParams.FLAG_FULLSCREEN
//        );// 设置全屏
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
//        hideActionBar()
        setContentView(R.layout.activity_splash)
//        startWindowsMainActivity()
//        startDialogMainActivity()
//        startStreamActivity()

//        startNewActivity(AiActivity::class.java)
//        startWindowsMainActivity(WebViewTestActivity::class.java)
//        startNewActivity(DensityTestActivity::class.java)
//        startNewActivity(CameraTestActivity::class.java)

    }

    private fun hideActionBar() {
        //        supportActionBar?.hide()

        // Hide the title bar for the Activity
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    private fun startNewActivity(cls:Class<*>){
        val intent = Intent(this, cls)
        startActivity(intent) //默认全屏模式启动
        finish()
    }

    private fun startStreamActivity() {
        val intent = Intent(this, LiveStreamActivity::class.java)
        startActivity(intent) //默认全屏模式启动
        finish()
    }

    private fun startDialogMainActivity() {
        val intent = Intent(this, MainActivity::class.java)
        startActivity(intent) //默认全屏模式启动
        finish()
    }

    private fun startWindowsMainActivity(cls:Class<*>) {
        val intent = Intent(this, cls)
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) //必须设置NEW_TASK标记

        val activityOptions: ActivityOptions = Utils.getFreeformWindowModeLaunchOptions()
        if (activityOptions != null) {
            startActivity(intent, activityOptions.toBundle()) //自由窗口模式启动
        } else {
            startActivity(intent) //默认全屏模式启动
        }

        finish()
    }
}